class Solution:
    def myAtoi(self, s: str) :
        l1=list(s)
        l2=[]
        l3=[]
        flagIndex=0
        for index,n in enumerate(l1):
            if (str.isdigit(n) or (n=='-' and len(l3)==0) or (n=='+' and len(l3)==0)) and  index==flagIndex  :
                l3.append(n)
                flagIndex = index + 1
            if( n==' 'and len(l3)==0):
                flagIndex+=1




        result=0
        if (len(l3) == 0):
            result = 0
        elif (str.isdigit(l3[0])==False and len(l3)==1):
            result=0
        else:result = int(''.join(l3))


        if result>2**31-1:
            result=2**31-1
        elif result<-2**31:
            result=-2**31
        return result

lll=Solution()
m1=print(lll.myAtoi("+-12"))